package com.example.hw_demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.hw_demo.entity.HwFacilityToilet;
import com.example.hw_demo.service.HwFacilityToiletService;
import com.example.hw_demo.mapper.HwFacilityToiletMapper;
import com.example.hw_demo.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
* @author 19643
* @description 针对表【hw_facility_toilet(公厕)】的数据库操作Service实现
* @createDate 2025-06-24 19:59:42
*/
@Service
public class HwFacilityToiletServiceImpl extends ServiceImpl<HwFacilityToiletMapper, HwFacilityToilet>
    implements HwFacilityToiletService{

    @Autowired
    HwFacilityToiletMapper hwFacilityToiletMapper;
    @Override
    public Result selectpage(HwFacilityToilet hwFacilityToilet) {
        Page<HwFacilityToilet> page =new Page<HwFacilityToilet>(hwFacilityToilet.getPage(),hwFacilityToilet.getSize());
        //条件查询
        QueryWrapper<HwFacilityToilet> queryWrapper = new QueryWrapper<HwFacilityToilet>();
        if(hwFacilityToilet.getName()!=null&&!"".equals(hwFacilityToilet.getName())) {
            queryWrapper.like("name", hwFacilityToilet.getName());
        }
        hwFacilityToiletMapper.selectPage(page,queryWrapper);
        List<HwFacilityToilet> list = page.getRecords();
        long total =page.getTotal();
        HashMap<String,Object> hashMap = new HashMap<String, Object>();
        hashMap.put("list",list);
        hashMap.put("total",total);
        return new Result(200,"查询成功",hashMap);
    }
}




